<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script src="assets/js/jquery.min.js"></script>
</head>
<body>
<div class="topbar-wrap white">
    <div class="topbar-inner clearfix">
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="index.html" class="navbar-brand">后台管理</a></h1>
            <ul class="navbar-list clearfix">
                <li><a class="on" href="index.html">首页</a></li>
                <li><a href="#" target="_blank">网站首页</a></li>
            </ul>
        </div>
        <div class="top-info-wrap">
            <ul class="top-info-list clearfix">
                <li><a href="#">管理员</a></li>
                <li><a href="#">修改密码</a></li>
                <li><a href="#">退出</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
        <div class="sidebar-content">
            <ul class="sidebar-list">
                <li>
                    <a href="#"><i class="icon-font">&#xe003;</i>常用操作</a>
                    <ul class="sub-menu">
                        <li><a href="index.html"><i class="icon-font">&#xe008;</i>用户管理</a></li>
                        <li><a href="products.html"><i class="icon-font">&#xe005;</i>作品管理</a></li>
                        <li><a href="sowing.html"><i class="icon-font">&#xe006;</i>轮播图管理</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe004;</i>留言管理</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe012;</i>评论管理</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe052;</i>友情链接</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe033;</i>广告管理</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="icon-font">&#xe018;</i>系统管理</a>
                    <ul class="sub-menu">
                        <li><a href="system.html"><i class="icon-font">&#xe017;</i>系统设置</a></li>
                        <li><a href="system.html"><i class="icon-font">&#xe037;</i>清理缓存</a></li>
                        <li><a href="system.html"><i class="icon-font">&#xe046;</i>数据备份</a></li>
                        <li><a href="system.html"><i class="icon-font">&#xe045;</i>数据还原</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/jscss/admin/design/">作品管理</a><span class="crumb-step">&gt;</span><span>新增作品</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="/jscss/admin/design/add" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <!-- <tbody><tr>
                            <th width="120"><i class="require-red">*</i>分类：</th>
                            <td>
                                <select name="colId" id="catid" class="required">
                                    <option value="">请选择</option>
                                    <option value="0">用户作品</option><option value="1">摄影师作品</option><option value="2">藏品</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th width="120"><i class="require-red">*</i>作品类型：</th>
                            <td>
                                <select name="colId" id="catid1" class="styletype">
                                    <option value="">请选择</option>
                                    <option value="0">景色</option><option value="1">生活</option><option value="2">人物</option>
                                </select>
                            </td>
                        </tr>
                            <tr>
                                <th><i class="require-red">*</i>作品名：</th>
                                <td>
                                    <input class="common-text required" id="title" name="title" size="50" value="" type="text">
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>相机型号：</th>
                                <td>
                                    <input class="common-text required" id="cameratype" name="title" size="50" value="" type="text">
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>作者：</th>
                                <td>
                                    <input class="common-text required" id="autor" name="title" size="50" value="" type="text">
                                </td>
                                <tr>
                                <th><i class="require-red">*</i>作品价格：</th>
                                <td>
                                    <input class="common-text required" id="price" name="title" size="50" value="" type="text">
                                </td>
                            </tr>
                            </tr>
                            <tr>
                                <th>拍摄地点：</th>
                                <td><input class="common-text" id="adress" size="50"  type="text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>缩略图：</th>
                                <td><input name="smallimg" id="smallimg" type="file"><input type="submit" onclick="submitForm('/jscss/admin/design/upload')" value="上传图片"/></td>
                            </tr>
                            <tr>
                                <th>作品简介：</th>
                                <td><textarea name="content" class="common-textarea" id="content" cols="30" style="width: 98%;" rows="10"></textarea></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" value="提交" type="button" id="sum">
                                    <input class="btn btn6" onClick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr> -->
                        </tbody></table>
                </form>
            </div>
        </div>
    </div>
    <!--/main-->
</div>
</body>
 <script type="text/javascript">
 function getUrlParam(name)
 	{
	 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	 var r = window.location.search.substr(1).match(reg);  //匹配目标参数
	 if (r!=null) return unescape(r[2]); return null; //返回参数值
 } 
 var condition = getUrlParam("condition");
 $(document).ready(function(){
	 var work_id = getUrlParam("work_id");
	$.post("updateworks", {"works.id":work_id}, function(data){
		var type="";
		if (data.styletype==0) {
			type="景色";
		} else if(data.styletype==1){
			type="生活";
		}else{
			type="人物";
		}
	
			$(".insert-tab").append('<tbody><tr>'+
           /*  '<th width="120"><i class="require-red">*</i>分类：</th>'+
            '<td>'+
               '<select name="colId" id="catid" class="required">'+
                    '<option value="" class="type">请选择</option>'+
                    '<option value="0">用户作品</option><option value="1">摄影师作品</option><option value="2">藏品</option>'+
                '</select>'+
            '</td>'+ */
        '</tr>'+
        '<tr>'+
            '<th width="120"><i class="require-red">*</i>作品类型：</th>'+
            '<td>'+
                '<select name="colId" id="catid1" class="styletype">'+
                    '<option value="0" class="type">'+type+'</option>'+
                    '<option value="0">景色</option><option value="1">生活</option><option value="2">人物</option>'+
                '</select>'+
            '</td>'+
        '</tr>'+
            '<tr>'+
                '<th><i class="require-red">*</i>作品名：</th>'+
                '<td>'+
                    '<input class="common-text required" id="title" name="title" size="50" value="'+data.name+'" type="text">'+
                '</td>'+
            '</tr>'+
            '<tr>'+
                '<th><i class="require-red">*</i>相机型号：</th>'+
                '<td>'+
                    '<input class="common-text required" id="cameratype" name="title" size="50" value="'+data.cameramodel+'" type="text">'+
                '</td>'+
            '</tr>'+
            '<tr>'+
                '<th><i class="require-red">*</i>作者：</th>'+
                '<td>'+
                    '<input class="common-text required" id="autor" name="title" size="50" value="'+data.autor+'" type="text">'+
                '</td>'+
                '<tr>'+
                '<th><i class="require-red">*</i>作品价格：</th>'+
                '<td>'+
                    '<input class="common-text required" id="price" name="title" size="50" value="'+data.price+'" type="text">'+
                '</td>'+
            '</tr>'+
            '</tr>'+
            '<tr>'+
                '<th>拍摄地点：</th>'+
                '<td><input class="common-text" id="adress" size="50"  type="text" value="'+data.location+'"></td>'+
            '</tr>'+
            '<tr>'+
                '<th><i class="require-red">*</i>缩略图：</th>'+
                '<td><img alt="" src="'+data.prhotourl+'" width="100px"></td>'+
            '</tr>'+
            '<tr>'+
                '<th>作品简介：</th>'+
                '<td><textarea name="content" class="common-textarea" id="content" cols="30" style="width: 98%;" rows="10">'+data.info+'</textarea></td>'+
            '</tr>'+
            '<tr>'+
                '<th></th>'+
                '<td>'+
                    '<input class="btn btn-primary btn6 mr10" value="提交" type="button" id="sum">'+
                    '<input class="btn btn6" onClick="history.go(-1)" value="返回" type="button">'+
                '</td>'+
            '</tr>');
			$("#sum").click(function(){
				var work_id = data.id; 
			 	var styletype = $("#catid1").val();
			 	var name=$("#title").val();
			 	var cameratype=$("#cameratype").val();
			 	var photourl = data.prhotourl;
			 	var autor = $("#autor").val();
			 	var phototime = data.phototime;
			 	var price = $("#price").val();
			 	var adress = $("#adress").val();
			 	var info = $("#content").val();
				var user_id =  $("#user_id").val();
				$.post("updatesaveworks", {
					"works.id":work_id,
					"works.cameramodel":cameratype,
					"works.info":info,
					"works.location":adress,
					"works.name":name,
					"works.phototime":phototime,
					"works.prhotourl":photourl,
					"works.price":price,
					"works.state":data.state,
					"works.styletype":styletype,
					"works.autor":autor,
					"works.user_id":user_id,

					}, function(data){
						if (data.isSuccess) {
							alert("修改成功");
						} else {
							alert("修改失败");
						}
					})
			})
            
		})

 })        
	 	
</script>
</html>